import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/sys_user/login',
    method: 'post',
    data
  })
}

export function getSmsCode(data) {
  return request({
    url: '/sys_user/get_sms_code',
    method: 'post',
    data
  })
}

export function getInfo() {
  return request({
    url: '/sys_user/info',
    method: 'get'
  })
}

export function logout() {
  return request({
    url: '/sys_user/logout',
    method: 'post'
  })
}


export function getAppUser(data) {
  return request({
    url: '/app_user',
    method: 'get',
    params: data
  })
}

export function getAppUserDetail(data) {
  return request({
    url: '/app_user/' + data,
    method: 'get'
  })
}

export function uploadUserList(data) {
  return request({
    url: '/app_user/upload_company_user',
    method: 'post',
    data
  })
}

export function addAppUser(data) {
  return request({
    url: '/app_user',
    method: 'post',
    data
  })
}

export function editAppUser(data) {
  return request({
    url: '/app_user/' + data.id,
    method: 'put',
    data
  })
}

export function removeAppUser(data) {
  return request({
    url: '/app_user/' + data,
    method: 'delete'
  })
}

export function getAppUserPackage(data) {
  return request({
    url: '/user_package',
    method: 'get',
    params: data
  })
}

export function getAppUserPackageDetail(data) {
  return request({
    url: '/user_package/' + data,
    method: 'get'
  })
}

export function addAppUserPackage(data) {
  return request({
    url: '/user_package',
    method: 'post',
    data
  })
}

export function editAppUserPackage(data) {
  return request({
    url: '/user_package/' + data.id,
    method: 'put',
    data
  })
}

export function removeAppUserPackage(data) {
  return request({
    url: '/user_package/' + data,
    method: 'delete'
  })
}

export function getBusinessPackage() {
  return request({
    url: '/business_package',
    method: 'get'
  })
}

export function getBusinessPackageDetail(data) {
  return request({
    url: '/business_package/' + data,
    method: 'get',
    params: data
  })
}

export function addBusinessPackage(data) {
  return request({
    url: '/business_package',
    method: 'post',
    data
  })
}

export function editBusinessPackage(data) {
  return request({
    url: '/business_package/' + data.id,
    method: 'put',
    data
  })
}

export function removeBusinessPackage(data) {
  return request({
    url: '/business_package/' + data,
    method: 'delete'
  })
}

export function getOrder(data) {
  return request({
    url: '/order',
    method: 'get',
    params:data,
  })
}

export function getOrderDetail(data) {
  return request({
    url: '/order/' + data,
    method: 'get'
  })
}

export function addOrder(data) {
  return request({
    url: '/order',
    method: 'post',
    data
  })
}

export function editOrder(data) {
  return request({
    url: '/order/' + data.id,
    method: 'put',
    data
  })
}

export function removeOrder(data) {
  return request({
    url: '/order/' + data,
    method: 'delete',
  })
}


export function getHouseHolder(data) {
  // return request({
  //   url: '/house_holder',
  //   method: 'get',
  //   params:data,
  // })
  if(data.export){
    return request({
      url: '/house_holder',
      method: 'get',
      params:data,
      responseType:'blob',
    })
  }
  return request({
    url: '/house_holder',
    method: 'get',
    params:data,
  })
}

export function getHouseHolderDetail(data) {
  return request({
    url: '/house_holder/' + data,
    method: 'get'
  })
}

export function addHouseHolder(data) {
  return request({
    url: '/house_holder',
    method: 'post',
    data
  })
}

export function editHouseHolder(data) {
  return request({
    url: '/house_holder/' + data.id,
    method: 'put',
    data
  })
}

export function removeHouseHolder(data) {
  return request({
    url: '/house_holder/' + data,
    method: 'delete',
  })
}

export function getComapanyUser(data) {
  // return request({
  //   url: '/house_holder',
  //   method: 'get',
  //   params:data,
  // })
  if(data.export){
    return request({
      url: '/company_user',
      method: 'get',
      params:data,
      responseType:'blob',
    })
  }
  return request({
    url: '/company_user',
    method: 'get',
    params:data,
  })
}
export function getComapanyUserDetail(data) {
  return request({
    url: '/company_user/' + data,
    method: 'get'
  })
}

export function addComapanyUser(data) {
  return request({
    url: '/company_user',
    method: 'post',
    data
  })
}

export function editComapanyUser(data) {
  return request({
    url: '/company_user/' + data.id,
    method: 'put',
    data
  })
}

export function removeComapanyUser(data) {
  return request({
    url: '/company_user/' + data,
    method: 'delete',
  })
}

export function addHouseHolderSeat(data) {
  return request({
    url: '/house_holder_seat',
    method: 'post',
    data
  })
}

export function editHouseHolderSeat(data) {
  return request({
    url: '/house_holder_seat/' + data.id,
    method: 'put',
    data
  })
}

export function removeHouseHolderSeat(data) {
  return request({
    url: '/house_holder_seat/' + data,
    method: 'delete',
  })
}

export function exportCountReport(data) {
  if(data.export){
    return request({
      url: '/order',
      method: 'get',
      params:data,
      responseType:'blob',
    })
  }
}
